home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / -archivi / -recent1 / nsm_invert.lha / invert / invertblock.c < prev    next >
C/C++ Source or Header  |  1999-02-23  |  977b  |  62 lines

  1. /*
  2.     Inverts the notes in the current block.
  3.  
  4.     Made by Kjetil S. Matheussen 22.2.99.
  5.  
  6.     Recommended shortcut: Left Amiga + Shift + i
  7.  
  8.     e-mail: kjetilma@ifi.uio.no
  9.  
  10.     Address:
  11.     Kjetil S. Matheussen
  12.     5423 Sogn Studentby
  13.     0858 Oslo
  14.     Norway
  15. */
  16.  
  17. #include "/nsm.h"
  18. #define TRUE 1
  19. #define FALSE 0
  20.  
  21. void main(){
  22.     OCTABASE ob;
  23.     BLOCKBASE bb;
  24.  
  25.     UWORD starttrack,endtrack;
  26.     UWORD    startline,endline;
  27.    UWORD current,post,last;
  28.  
  29.     UWORD track,line;
  30.  
  31.     int first;
  32.  
  33.  
  34.     if((ob=getoctabase())==0) goto exit;            /* Allways include this line first in
  35.                                                                     your plug-ins. */
  36.     bb=getcurrblockbase(ob);
  37.  
  38.     endtrack=getnumtracks(bb);
  39.     endline=getnumlines(bb)-1;
  40.  
  41.     for(track=0;track<=endtrack;track++){
  42.         first=TRUE;
  43.         for(line=0;line<=endline;line++){
  44.             current=getnote(bb,track,line);
  45.             if(current){
  46.                 if(!first){
  47.                     last=last+post-current;
  48.                     setnote(bb,track,line,last);
  49.                 }else{
  50.                     last=current;
  51.                     first=FALSE;
  52.                 }
  53.                 post=current;
  54.             }
  55.         }
  56.     }
  57.  
  58.     updateeditor(ob);
  59.  
  60. exit:
  61. }
  62.